<template>
  <div style="background: #FFFFFF;padding: 20px 10px 10px 10px">
    <!--查询区域-->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="3" :lg="7" :md="8" :sm="24">
            <a-form-item label="工序">
              <j-dict-select-tag
                  placeholder="请选择工序"
                  v-model="queryParam.procedure"
                  dictCode="procedure"
                  @change="loadData(1)" />
            </a-form-item>
          </a-col>
          <a-col :xl="3" :lg="7" :md="8" :sm="24">
            <a-form-item label="品名">
              <j-input placeholder="请输入品名" v-model="queryParam.productName" @change="loadData(1)" />
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-item label="品种全称">
              <j-input placeholder="请输入品种全称" v-model="queryParam.productFullName" @change="loadData(1)" />
            </a-form-item>
          </a-col>
          <a-col :xl="14" :lg="4" :md="4" :sm="24">
            <div style="display: flex; justify-content: flex-end">
               <a-button type="primary" @click="handleAdd">新增定额</a-button>
               <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
                <a-button type="primary" style="margin-left: 8px">导入定额</a-button>
              </a-upload>
               <a-button type="primary" style="margin-left: 8px" @click="handleExportXls('定额表')">导出定额</a-button>
               <a-button type="primary" style="margin-left: 8px" @click="batchDel">批量删除</a-button>
            </div>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!--表格区域-->
    <div>
      <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          class="j-table-force-nowrap common-table"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          :scroll="{ x: true }"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <!--新增编辑-->
    <XiShaModal ref="modalForm" @ok="modalFormOk"></XiShaModal>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import JInput from '@/components/jeecg/JInput'
import XiShaModal from '@views/SystemManage/Quota/XiShaModal'

export default {
  mixins: [JeecgListMixin],
  components: {
    XiShaModal,
    JInput,
    JDictSelectTag
  },
  data() {
    return {
      columns: [
        {
          title: '工序',
          dataIndex: 'workingProcedure_dictText',
          align: 'center'
        },
        {
          title: '代号',
          dataIndex: 'codeName',
          align: 'center'
        },
        {
          title: '品名',
          dataIndex: 'productName',
          align: 'center'
        },
        {
          title: '品种全称',
          dataIndex: 'productFullName',
          align: 'center'
        },
        {
          title: '批号',
          dataIndex: 'productBatch',
          align: 'center'
        },
        {
          title: '支别',
          dataIndex: 'productBranch',
          align: 'center'
        },
        {
          title: '管色',
          dataIndex: 'tubeColor',
          align: 'center'
        },
        {
          title: '内袋',
          dataIndex: 'innerPocket',
          align: 'center'
        },
        {
          title: '捆绳',
          dataIndex: 'twine',
          align: 'center'
        },
        {
          title: '锭数',
          dataIndex: 'ingot',
          align: 'center'
        },
        {
          title: '定量换数系数',
          align: 'center',
          children: [
            {
              title: '棉',
              dataIndex: 'commutationCotton',
              align: 'center'
            },
            {
              title: '其它',
              dataIndex: 'commutationOther',
              align: 'center'
            },
            {
              title: '综合',
              dataIndex: 'commutationComprehensive',
              align: 'center'
            }
          ]
        },
        {
          title: '定量',
          dataIndex: 'ration',
          align: 'center'
        },
        {
          title: '车速',
          dataIndex: 'speed',
          align: 'center'
        },
        {
          title: '效率',
          dataIndex: 'efficiency',
          align: 'center'
        },
        {
          title: '长度百米',
          dataIndex: 'length',
          align: 'center'
        },
        {
          title: '重量 KG/日/台',
          dataIndex: 'weight',
          align: 'center'
        },
        {
          title: '单锭重量 KG/日/台',
          dataIndex: 'singleIngotWeight',
          align: 'center'
        },
        {
          title: '重量时间单位',
          dataIndex: 'weightTimeUnit',
          align: 'center'
        },
        {
          title: '定额看台',
          dataIndex: 'quota',
          align: 'center'
        },
        {
          title: '损耗率',
          dataIndex: 'lossRate',
          align: 'center'
        },
        {
          title: '成包标准毛重',
          dataIndex: 'grossWeight',
          align: 'center'
        },
        {
          title: '实际车速',
          dataIndex: 'actualSpeed',
          align: 'center'
        },
        {
          title: '操作',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/crm_product_type/crmProductType/list', //查询列表
        delete: '/crm_product_type/crmProductType/delete', //删除记录
        deleteBatch: '/crm_product_type/crmProductType/deleteBatch', //批量删除
        exportXlsUrl: '/crm_product_type/crmProductType/exportXls', //导出excel
        importExcelUrl: '/crm_product_type/crmProductType/importExcel' //导入excel
      }
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  }
}
</script>

